<?php
/**
 *   Joomdiet - components/joomdiet.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2010 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.mootools');
// Require the base controller
require_once JPATH_COMPONENT.DS.'controller.php';

// Require fron menu helper
require_once JPATH_COMPONENT.DS.'helpers'.DS.'menuhelper.php';

// Initialize component menu
$menu = JoomdietHelperFrontMenu::getInstance();
$menu->add_entry(JText::_('COM_JOOMDIET_FOOD_SEARCH_TITLE'), 'foodsearch');
$menu->add_entry(JText::_('COM_JOOMDIET_RECIPE_SEARCH_TITLE'), 'recipesearch');
$menu->add_entry(JText::_('COM_JOOMDIET_DIET_CALIBRATOR_TITLE'), 'dietcalibrator');
$menu->add_entry(JText::_('COM_JOOMDIET_RECOMMENDED_TITLE'), 'recommended');
$menu->add_entry(JText::_('COM_JOOMDIET_ENERGETIC_SPEND_TITLE'), 'energeticspend');
//$menu->add_entry(JText::_('COM_JOOMDIET_DIET_GENERATOR_TITLE'), 'dietgenerator');

// loading base style sheet
$document =& JFactory::getDocument();
$document->addStyleSheet('components'.DS.'com_joomdiet'.DS.'assets'.DS.'css'.DS.'base.css');

// Initialize the dedicated controller
if ($controller = JRequest::getWord('controller')) {
    // determine path
    $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
    if (file_exists($path)) {
        require_once $path;
    } else $controller = '';
}

$classname = 'JoomdietController'.$controller;
$controller = new $classname();

// Redirect if set by the controller
$controller->execute(JRequest::getVar('task'));
$controller->redirect();
?>
